- won = @account.opportunities.won.map(&:amount).compact.sum
- lost = @account.opportunities.lost.map(&:amount).compact.sum
- pipeline = @account.opportunities.pipeline.map(&:weighted_amount).compact.sum

.panel#summary
  - if @account.website
    %div
      %b= link_to(truncate(@account.website, length: 30), @account.website.to_url, :"data-popup" => true, title: t(:open_in_window, @account.website))
  - if @account.email.present?
    %div
      %b= link_to_email(@account.email, 30)

  %div
    - if @account.toll_free_phone
      == #{t :phone_toll_free}: <b>#{link_to_phone(@account.toll_free_phone)}</b><br />

    - if @account.phone
      == #{t :phone}: <b>#{link_to_phone(@account.phone)}</b><br />

    - if @account.fax
      == #{t :fax}: <b>#{link_to_phone(@account.fax)}</b><br />

    %div= render "shared/address_show", asset: @account, type: 'billing', title: :billing_address
    %div= render "shared/address_show", asset: @account, type: 'shipping', title: :shipping_address


  - if @account.latitude.present? && @account.longitude.present?
    #map{style: "width: 100%; height: 150px;"}

    %p.text-end
      %small
        %b= link_to "Google Maps", "https://www.google.com/maps/search/?api=1&query=#{@account.latitude},#{@account.longitude}", target: "_blank"
        |
        %b= link_to "Other", "geo:#{@account.latitude},#{@account.longitude}"

  .caption #{t :account_summary}
  %dl
    %li
      %dt= display_value(pipeline)
      %tt #{t :pipeline}:
    %li
      %dt= display_value(won)
      %tt #{t :won}:
    %li
      %dt= display_value(lost)
      %tt #{t :lost}:
    %li
      %dt= @account.category ? t(@account.category) : t(:other)
      %tt #{t :category}:
    %li
      %span{style: "float:right;"}= stars_for(@account)
      %tt #{t :rating}:
    %li
      %dt= display_assigned(@account)
      %tt #{t :assigned_to}:

  - unless @account.background_info.blank?
    .caption #{t :background_info}
    = auto_link(simple_format @account.background_info)

  = render "fields/sidebar_show", asset: @account

  - if @account.tags.present?
    %dt
      .tags= tags_for_index(@account)

  = render "shared/research_tools", entity: @account

  = hook(:show_account_sidebar_bottom, self, account: @account)

- if @account.latitude.present? && @account.longitude.present?
  :javascript
    var map = L.map('map').setView([#{@account.latitude}, #{@account.longitude}], 18);
    L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
        attribution: '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors'
    }).addTo(map);
    L.marker([#{@account.latitude}, #{@account.longitude}]).addTo(map);
